/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.BasicInteractions;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.modeler.model.common.MetaTypedList;
import edu.pku.sei.modeler.model.uml.Kernel.NamedElement;
import edu.pku.sei.modeler.model.uml.Kernel.ValueSpecification;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Message extends NamedElement implements IMessage {
	// attributes
	
	protected MessageKind messageKind;
	
	protected MessageSort messageSort;
	
	protected MessageEnd sendEvent;
	
	protected MessageEnd receiveEvent;
	
	
	
	
	// references
	
	protected MetaTypedList argument;
	
	
	
	// getters & setters for attributes
	
	public MessageKind getMessageKind() {
		return messageKind;
	}
	public void setMessageKind(MessageKind newMessageKind) {
		MessageKind oldmessageKind = messageKind;
		messageKind = newMessageKind;
		firePropertyChange(ModelPackage.MESSAGE_MESSAGEKIND, oldmessageKind, newMessageKind);
	}
	
	public MessageSort getMessageSort() {
		return messageSort;
	}
	public void setMessageSort(MessageSort newMessageSort) {
		MessageSort oldmessageSort = messageSort;
		messageSort = newMessageSort;
		firePropertyChange(ModelPackage.MESSAGE_MESSAGESORT, oldmessageSort, newMessageSort);
	}
	
	public MessageEnd getSendEvent() {
		return sendEvent;
	}
	public void setSendEvent(MessageEnd newSendEvent) {
		MessageEnd oldsendEvent = sendEvent;
		sendEvent = newSendEvent;
		firePropertyChange(ModelPackage.MESSAGE_SENDEVENT, oldsendEvent, newSendEvent);
	}
	
	public MessageEnd getReceiveEvent() {
		return receiveEvent;
	}
	public void setReceiveEvent(MessageEnd newReceiveEvent) {
		MessageEnd oldreceiveEvent = receiveEvent;
		receiveEvent = newReceiveEvent;
		firePropertyChange(ModelPackage.MESSAGE_RECEIVEEVENT, oldreceiveEvent, newReceiveEvent);
	}
	
	// getters for references
	
	public MetaTypedList getArgument() {
		if(argument == null) {
			argument = new MetaTypedList(ValueSpecification.class, this, ModelPackage.MESSAGE_ARGUMENT);
		}
		return argument;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.MESSAGE_MESSAGEKIND, messageKind);
		
		XMLUtility.xmlInstance.serializeAttribute(root,
				ModelPackage.MESSAGE_MESSAGESORT, messageSort.getValue());
		
		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.MESSAGE_SENDEVENT, sendEvent);
		
		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.MESSAGE_RECEIVEEVENT, receiveEvent);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.MESSAGE_ARGUMENT, argument);
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		messageKind = (MessageKind)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.MESSAGE_MESSAGEKIND, this);
		
		messageSort = new MessageSort(XMLUtility.xmlInstance.deSerializeInt(
				root, ModelPackage.MESSAGE_MESSAGESORT)) ;
		
		sendEvent = (MessageEnd)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.MESSAGE_SENDEVENT, this);
		
		receiveEvent = (MessageEnd)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.MESSAGE_RECEIVEEVENT, this);
		
		// references
		
		this.getArgument().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.MESSAGE_ARGUMENT));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.MESSAGE_MESSAGEKIND.equals(featureID)) {
			messageKind = (MessageKind)value;
		}
		
		else if(ModelPackage.MESSAGE_MESSAGESORT.equals(featureID)) {
			messageSort = (MessageSort)value;
		}
		
		else if(ModelPackage.MESSAGE_SENDEVENT.equals(featureID)) {
			sendEvent = (MessageEnd)value;
		}
		
		else if(ModelPackage.MESSAGE_RECEIVEEVENT.equals(featureID)) {
			receiveEvent = (MessageEnd)value;
		}
		
		// references
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 